package dao;

import com.mysql.jdbc.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 */
public class DbHandler {
    /**
     */
    private String dbpath;
    private String host;
    private String user;
    private String pass;
    private String driver= "com.mysql.jdbc.Driver";
    public Connection conn;
   

     public String getDbpath(){
    return dbpath;
    }
    public void setDbpath(String dbpath){
    this.dbpath =dbpath;
    }
    public String getHost(){
    return host;
    }
    public void setHost(String host){
    this.host=host;
    }
    public String getUser(){
    return user;
    }

    public void setUser(String user){
    this.user=user;
    }

    public String getPass(){
    return pass;
    }

    public void setPass(String pass){
    this.pass = pass;
    }

    /**
     * @param sql 
     */
    
    public void runSql(String sql) throws Exception {
        String url="jdbc:mysql://localhost:3306/moodle";
        try
        {
            Class.forName(driver); //se
            conn = DriverManager.getConnection(url,"root","episunsa");
            Statement st = (Statement) conn.createStatement();
            st.execute(sql);
         System.out.println("sql:"+sql);

            System.out.println("Conexión establecida");
        }
        catch (Exception ex)
        {
            throw new Exception(ex);
        }
        conn.close();
   }
}